<script setup name="Child" lang="ts">
const { count = 10 } = defineProps<{
  count?: number
}>()

// 传统写法
/* const emits = defineEmits(['changeCount'])
const handleClick = (num: number) => {
  emits('changeCount', num)
} */

const emits = defineEmits<{
  (e: 'changeCount', num: number): void
  (e: 'changeAge', age: number): void
}>()
const handleClick = (num: number) => {
  emits('changeCount', num)
}

const changeAge = (age: number) => {
  emits('changeAge', age)
}
</script>
<template>
  <div>Child: {{ count }}</div>
  <button @click="handleClick(2)">change parent count</button>
  <button @click="changeAge(2)">change parent count</button>
</template>
